#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>

#include "rand.h"

int get_rand_num()
{
	struct timeval my_time;
	gettimeofday(&my_time, NULL);
	srand(my_time.tv_usec);
	return rand();
}


char get_rand_char()
{
	int rand_num = 0;
	while(1)
	{
		rand_num = get_rand_num()%123;
		if(((rand_num>64)&&(rand_num<91))||(rand_num>97))
			break;
	}

	return (char)rand_num;	
}


char *get_rand_str(char *p, int len)
{
	if(p==NULL)
		return NULL;
	
	int i;
	for(i=0;i<len-1;i++)
		p[i] = get_rand_char();

	p[len-1]='\0';

	return p;
}

